<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserWalletActivesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_wallet_actives', function (Blueprint $table) {
            $table->id();
            $table->bigInteger('user_id')->unsigned()->comment('用户ID');
            $table->bigInteger('operator_id')->default(0)->comment('操作人');
            $table->char('wallet_type', 50)
                ->default(\App\Constant\Enum::WALLET_TYPE_REWARD)->index()
                ->comment('账户类型');
            $table->bigInteger('coins')->default(0)->comment('数量');
            $table->bigInteger('before_reward_coins')->default(0)
                ->comment('变动前收益金币');
            $table->bigInteger('after_reward_coins')
                ->default(0)
                ->comment('变动后收益金币');
            $table->bigInteger('before_commission_coins')
                ->default(0)
                ->comment('变动前佣金金币');
            $table->bigInteger('after_commission_coins')
                ->default(0)
                ->comment('变动后佣金金币');
            $table->timestamp('changed_at')
                ->nullable()
                ->index()
                ->comment('变更时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_wallet_actives');
    }
}
